package com.fattyCorps.game.app;

import cn.hutool.extra.spring.SpringUtil;
import com.fattyCorps.game.service.GlobalService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

@Component
public class App implements CommandLineRunner {

    private void init() {
        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
            @Override
            public void run() {
                SpringUtil.getBean(GlobalService.class).onServerClose();
            }
        }));
    }

    @Override
    public void run(String... args) throws Exception {
        init();
    }
}
